import { baseRequestClient } from '#/api/request'
import { requestClient } from '#/api/request';
export async function getTubesApi() {
  return baseRequestClient.get('http://localhost:5320/api/gis/xzj-tube')
}

// ----------------------------------

// 查询油水井返回值
interface ListPipelineResult {
  rows: any;
  total: number;
}

// 查询管线（油气/注水）列表
export const listPipeline = async (params: {
  page: number;
  pageSize: number;
  // 可以根据需要添加其他查询参数
}) => {
  const response = await requestClient.get<ListPipelineResult>('/manage/pipeline/list', { params });
  const data = response.rows; // 提取 rows 字段
  const total = response.total;
  const start = (params.page - 1) * params.pageSize;
  const end = start + params.pageSize;
  const result = data.slice(start, end);

  const mappedResult = result.map((row: any) => {
    return {
        ...row,
        pipeType: row.pipeType === 0 ? '油气':'注水'
      };
    });

  return {
    items: mappedResult,
    total: total,
  };
};

// 查询管线（油气/注水）详细
export async function getPipeline(id:number) {
  return baseRequestClient.get(`/manage/pipeline/${id}`);
}

// 新增管线（油气/注水）
